package com.weilive.core.protocol.protobuf;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.protobuf.MessageLite;
import com.weilive.core.protocol.PacketError;

public abstract class ProtobufRequestHandler {

	protected static Logger log = LoggerFactory.getLogger(ProtobufRequestHandler.class);

	public abstract MessageLite getRequestType();

	public abstract MessageLite getResponseType();

	public abstract ProtobufResponse handleRequest(ProtobufRequest request) throws Exception;

	public long getRequestFrequency() {
		return 100L;
	}

	public ProtobufResponse createErrorResponse(PacketError error) {
		return ProtobufResponse.create(error, getResponseType());
	}

	public ProtobufResponse createResponse(MessageLite.Builder data) {
		return ProtobufResponse.create(data);
	}
}
